// #define print(...)
class Solution {
public:
int hIndex(vector<int>& citations) {
    vector<uint32_t> cnt(citations.size()+1, 0);
    for(auto&c:citations)
        cnt[c>=cnt.size()?cnt.size()-1:c]++;
    print("cnt=", cnt, "\n")
    
    for(int i=(int)cnt.size()-1; i>=0;){
        if(*cnt.rbegin() >= i)
            return i;
        *cnt.rbegin() += cnt[--i];
    }
    return 0;
}
};
